package com.serviceprovider.business.module.admin.license.services.dao.impl;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.admin.acl.utility.IAclSecurityUtil;
import com.serviceprovider.business.module.admin.license.model.License;
import com.serviceprovider.business.utility.maintenance.settings.RoleUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.acls.domain.BasePermission;
import org.springframework.security.acls.sid.GrantedAuthoritySid;
import org.springframework.security.acls.sid.PrincipalSid;
import org.springframework.security.acls.sid.Sid;
import org.springframework.stereotype.Repository;

@Repository("securityService")
public class SecurityServiceImpl
        implements com.serviceprovider.business.module.admin.license.services.dao.interfaces.ISecurityService {
    @Autowired
    @Qualifier("aclSecurity")
    private IAclSecurityUtil aclSecurityUtil;

    public void setLicensePermissions(License license) {
        Sid sid      = new PrincipalSid(RoleUtils.ROLE_USER);
        Sid sidAdmin = new GrantedAuthoritySid(RoleUtils.ROLE_ADMINISTRATOR);

        aclSecurityUtil.addPermission(license, sid, BasePermission.ADMINISTRATION, License.class);
        aclSecurityUtil.addPermission(license, sidAdmin, BasePermission.ADMINISTRATION, License.class);
    }
}



